#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
//#pragma GCC optimize(2)
//#pragma GCC optimize(3)
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
//#include <immintrin.h>
//#include <emmintrin.h>
#define int long long
#define ls(x) ((x)*2)
#define rs(x) ((x)*2+1)
#define fi first
#define se second
#define pii pair<int,int>
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define For(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define Rof(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define rep(i,  b) for(int i=1,i##end=b;i<=i##end;i++)
using namespace std;
const int N=1e6+5,base=999983,Mod=1e9+7;
//char buf[(1<<21)+5],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline void chmx(int &x,int y){(x<y)&&(x=y);}
inline void chmn(int &x,int y){(x>y)&&(x=y);}
inline void Add(int &x,int y){(x=x+y+Mod)%=Mod;}
inline int read(){
	int f=0,x=0;
	char ch=getchar();
	while(!isdigit(ch)){f|=(ch=='-');ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	return f?-x:x;
}
void print(int n){
    if(n<0){
        putchar('-');
        n*=-1;
    }
    if(n>9) print(n/10);
    putchar(n%10+'0');
}
int n,k;
char s[N],L[N],R[N];
int dp[1005][1005][2][2];
int f[1005][1005][2][2];
signed main(){
	freopen("lost.in","r",stdin);
	freopen("lost.out","w",stdout);
	// ios::sync_with_stdio(false);
	// cin.tie(0); cout.tie(0);
	n=read(),k=read();
	scanf("%s",s+1);
	scanf("%s",L+1);
	scanf("%s",R+1);
	if(L[1]!='1'||R[1]!='1'){
		puts("0");return 0;
	}
	dp[1][0][1][1]=1;
	f[1][0][1][1]=1;
	For(i,1,n-1)For(j,0,k)For(l,0,1)For(r,0,1){
		For(p,0,1)if(j+p<=k){
			int c=(s[i]=='L'?((j+p)&1):1-((j+p)&1));
			if(l&&c<L[i+1]-'0')continue;
			if(r&&c>R[i+1]-'0') continue;
			(dp[i+1][j+p][l&(c==L[i+1]-'0')][r&(c==R[i+1]-'0')]+=dp[i][j][l][r])%=Mod;
			(f[i+1][j+p][l&(c==L[i+1]-'0')][r&(c==R[i+1]-'0')]+=f[i][j][l][r]*2+dp[i][j][l][r]*c)%=Mod;
		}
	}
	int ans=0;
	For(l,0,1)For(r,0,1){
		ans+=f[n][k][l][r];ans%=Mod;
	}
	memset(dp,0,sizeof(dp));memset(f,0,sizeof(f));
	dp[1][0][1][1]=1;
	f[1][0][1][1]=1;
	For(i,1,n-1)For(j,0,k)For(l,0,1)For(r,0,1)if(dp[i][j][l][r]){
		For(p,0,1){
			int c=(s[i]=='L'?1-((j+p)&1):((j+p)&1));
			if(l&&c<L[i+1]-'0')continue;
			if(r&&c>R[i+1]-'0') continue;
			(dp[i+1][j+p][l&(c==L[i+1]-'0')][r&(c==R[i+1]-'0')]+=dp[i][j][l][r])%=Mod;
			(f[i+1][j+p][l&(c==L[i+1]-'0')][r&(c==R[i+1]-'0')]+=f[i][j][l][r]*2+dp[i][j][l][r]*c)%=Mod;
		}
	}
	For(l,0,1)For(r,0,1){
		ans+=f[n][k][l][r];ans%=Mod;
	}
	printf("%lld\n",ans);
#ifdef LOCAL
    Debug("\nMy Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

